package com.neu;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.neu.util.DateConverter;
import com.neu.util.LoginCheckInteceptor;

@SpringBootConfiguration
@MapperScan("com.neu.mapper")
public class AppConfig implements WebMvcConfigurer {
	//全局的跨域配置
	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**")//设置所有处理器都可以跨域访问
			.allowedOrigins("*")//支持哪些域对处理器访问
			.allowedMethods("*")//支持哪些请求方法（post,get）
			.allowCredentials(true);//支持证书		
	}
	//全局日期格式化处理
	@Override
	public void addFormatters(FormatterRegistry registry) {
		DateConverter d = new DateConverter();
		registry.addConverter(d);
	}
	
//	@Override
//	public void addInterceptors(InterceptorRegistry registry) {
//		registry.addInterceptor(new LoginCheckInteceptor())
//			//拦截那些请求
//			.addPathPatterns("/**")
//			//排除哪些请求
//			.excludePathPatterns("/user/login");
//	}
}
